<!-- 添加周检查 -->
<template>
	<view class="content page">
		<view class="duild_con">
			<view class="duild_list" @click="goDuildInfo()">
				<view class="company">
					<view class="duild_intro">
						<view class="intro">
							<text>企业</text>
							<text></text>
						</view>
					</view>
					<view class="gt">
						<text>{{form.areaName}}</text>
						<text>
						<u-icon name="arrow-right" color="#999999" size="24"></u-icon></text>
					</view>
				</view>
				<view class="company" style="border: none;">
					<view class="duild_intro">
						<view class="intro">
							<text>位置</text>
							<text></text>
						</view>
					</view>
					<view class="gt">
						<text>{{form.areaName}}</text>
						<text>
						<u-icon name="arrow-right" color="#999999" size="24"></u-icon></text>
					</view>
				</view>
			</view>
			<view class="temperature" @click="showDate = true">
				<view class="">
					日期
				</view>
				<view class="">
					{{form.inspectionDate}}
				</view>
			</view>

			<view class="lhwh_con">
				<view class="">
					备注
				</view>
				<textarea v-model="form.remark" auto-height maxlength="200" placeholder="请输入最多200个字符…"></textarea>
			</view>
<!--			<view class="upload_img">-->
<!--				<u-upload :max-size="1 * 1024 * 1024" max-count="3" ref="uUpload" :action="action" :auto-upload="false"></u-upload>-->
<!--				<text style="font-size: 24rpx;color: #999999;">请上传小于1M图片，最多3张</text>-->
<!--			</view>-->
			<view class="lhwh_sub" @click="submit()">
				提交
			</view>
		</view>
		<u-select value-name="id" cancel-color="#999999" confirm-color="#44D94B" label-name="areaName" v-model="show" :list="list" @confirm="confirm"></u-select>
		<u-calendar v-model="showDate" :mode="mode" @change="change"></u-calendar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				action: 'http://www.example.com/upload',
				form: {
					areaName: '',
					areaId: '',
					weather: '',
					temperature: '',
					remark: '',
					content: [],
					inspectionDate: ''
				},
				rules: {
					areaName: [{
						required: true,
						message: '请选择绿化区域',
						// 可以单个或者同时写两个触发验证方式
						trigger: ['change', 'blur'],
					}]
				},
				list: [],
				show: false,
				areaName: '',
				areaId: '',
				temperature: '',
				showDate: false,
				mode: 'date'

			};
		},
		// 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
		onShow() {
			this.reset()
		},
		onReady() {
			// this.$refs.uForm.setRules(this.rules);
		},
		onLoad(option) {
			this.buiGreenAreaList()
		},
		methods: {
			reset() {
				this.form = {}
			},
			getTitle(title) {
				uni.setNavigationBarTitle({
					title: title
				});
			},
			buiGreenAreaList() {
				//联网加载数据
				this.apis.greencleanApi.buiGreenAreaList().then(res => {
					this.list = res.rows
				}).catch(() => {
					//联网失败的回调,隐藏下拉刷新的状态
				})
			},
			goDuildInfo(i) {
				this.show = true
			},
			confirm(e) {
				this.form.areaName = e[0].label
				this.form.areaId = e[0].value
			},
			submit() {
				console.log(this.form.temperature)
				if (this.form.areaId === undefined || this.form.temperature === undefined) {
					this.showToast("填写完内容！")
					return
				} else {
					const content = JSON.parse(JSON.stringify(this.form.content))
					this.form.content = content.join(',')
					//联网加载数据
					this.apis.greencleanApi.addBuiGreenRecord(this.form).then(res => {
						uni.navigateTo({
							url: './successfully?id=' + res.msg
						})
						this.form = {}
					}).catch(() => {
						//联网失败的回调,隐藏下拉刷新的状态
					})
				}
			},
			change(e) {
				console.log(e);
				this.form.inspectionDate = e.result
			},
			submit() {
				this.$refs.uUpload.upload();
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		padding: 0;
	}

	.content {
		/deep/ .u-list-item {
			margin-left: 0;
		}

		/deep/ .u-add-tips {
			display: none;
		}

		/deep/ .u-calendar__action {
			display: flex;
			justify-content: center;
		}

		/deep/ .u-add-wrap {
			color: #CCCCCC;
		}
		.duild_con {
			overflow-y: auto;
			height: 1160rpx;
		}

		.duild_list {
			padding:0 30rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: center;
			border-radius: 12rpx;

			.company {
				width: 100%;
				display: flex;
				justify-content: space-between;
				padding: 30rpx 0;
				border-bottom: 1rpx solid #EEE;
			}

			.duild_intro {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				color: #666666;
				font-size: 28rpx;

				.intro {
					display: flex;
					font-size: 28rpx;
					justify-content: space-between;
					font-weight: 500;
				}
			}

			.gt {
				color: #999999;
				font-size: 26rpx;

				text:nth-child(1) {
					font-size: 28rpx;
					color: #333333;
					margin-right: 10rpx;
				}
			}
		}


		.temperature {
			padding: 30rpx;
			background: #FFFFFF;
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 28rpx;
			color: #666666;
			margin: 20rpx 0;
			border-radius: 12rpx;

			view:nth-child(2) {
				color: #333333;
			}
		}


		.lhwh_con {
			display: flex;
			flex-direction: column;
			background: #FFFFFF;
			padding: 40rpx 30rpx;
			margin-bottom: 20rpx;
			align-items: flex-start;
			border-radius: 12rpx;

			view {
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
			}

			/deep/ .uni-textarea-wrapper {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 40rpx;
			}

			/deep/ .uni-textarea-placeholder {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
				line-height: 40rpx;
			}

			textarea {
				margin-top: 20rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				min-height: 200rpx;
			}
		}

		.lhwh_sub {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			padding: 28rpx 0;
			background: #44D94B;
			font-size: 34rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			@include flexCenter
		}
		.upload_img{
			/deep/ .u-iconfont{
				font-size: 80rpx !important;
			}
		}
	}
</style>
